#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <regsys.h>

#include <QPushButton>
#include <QLabel>
#include <QVBoxLayout>
#include <QHBoxLayout>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->setWindowTitle("仓库管理系统");
    resize(400,300);
    //定义欢迎页面基本按钮
    QPushButton *BtnClose = new QPushButton(this);
    BtnClose->setText("关闭程序");
    QPushButton *BtnStart = new QPushButton(this);
    BtnStart->setText("系统启动");
    QLabel *ImageLabel = new QLabel();//用于写入文本

    connect(BtnClose, &QPushButton::pressed,
            [=]()
    {
        this->close();
    }
    );
    connect(BtnStart, &QPushButton::released,
            [=]()
    {
        regSys *reg = new regSys();
        reg->show();
        this->hide();
    }
    );


    //对按钮进行水平和垂直布局
    QVBoxLayout *VBox = new QVBoxLayout(ui->centralwidget);
    QHBoxLayout *HBox = new QHBoxLayout();
    VBox->addWidget(ImageLabel);
    HBox->addStretch();
    HBox->addWidget(BtnStart);
    HBox->addStretch();
    HBox->addWidget(BtnClose);
    HBox->addStretch();
    VBox->addLayout(HBox);

    ImageLabel->setText("<center><h1><a>欢迎使用仓库管理系统</a></h1></center>");

}

MainWindow::~MainWindow()
{
    delete ui;
}

